package 中国慕课课后作业章节4;

import java.util.ArrayList;

class Item{
    private String title;
    private int playTime;
    private boolean gotIt = false;
    private String comment;
    public Item(String title,int playTime,boolean gotIt,String comment)
    {
        this.title=title;
        this.playTime=playTime;
        this.gotIt=gotIt;
        this.comment=comment;
    }
    public void print()
    {
        System.out.print("title:"+title+";"+"playTime:"+playTime+";"+"gotIt:"+gotIt+";"+"comment:"+comment+";");
    }
}
class MP3 extends Item{
    private String artist;
    private int numofTracks;
    public MP3(String title, int playTime, boolean gotIt, String comment,String artist,int numofTracks)
    {
        super(title, playTime, gotIt, comment);
        this.artist=artist;
        this.numofTracks=numofTracks;
    }
    public void print()
    {
        System.out.print("MP3[");
        super.print();
        System.out.println("artist:"+artist+";"+"numofTracks:"+numofTracks+"}");
    }
}
public class Database {
    private ArrayList<Item> list=new ArrayList<Item>();
    public void add(Item item)
    {
        list.add(item);
    }

    public void list()
    {
        for(Item item:list)
            item.print();
    }
    public static void main(String[] args) {
        Database db=new Database();
        db.add(new MP3("A", 60, true, "good", "John", 20));
        db.add(new MP3("B", 80, true, "vrey good", "Tom", 10));
        db.list();
    }
}